package com.leo;

import com.jfoenix.controls.JFXHamburger;
import com.jfoenix.controls.JFXListView;
import com.jfoenix.controls.JFXPopup;
import com.jfoenix.controls.JFXRippler;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

import java.net.URL;

/**
 * @ClassName JFXPopupDemo
 * @Description
 * @Author wangss
 * @date 2020.11.26 14:39
 * @Version 1.0
 */
public class JFXPopupDemo extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {

        StackPane root = new StackPane();
        JFXListView<String> list = new JFXListView<String>();
        for(int i = 1 ; i < 5 ; i++) {
            list.getItems().add("Item " + i);
        }

        JFXHamburger burger = new JFXHamburger();
        burger.setPadding(new Insets(10,5,10,5));
        JFXRippler popupSource = new JFXRippler(burger, JFXRippler.RipplerMask.CIRCLE, JFXRippler.RipplerPos.BACK);

        JFXPopup popup = new JFXPopup();
//        popup.setContent(list);
//        popup.setPopupContainer(root);
//        popup.setSource(popupSource);
//        popupSource.setOnMouseClicked((e)-> popup.show(JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.LEFT));

        AnchorPane an = new AnchorPane();
        an.getChildren().addAll(root);

        Scene scene = new Scene(an);
        URL url = this.getClass().getResource("/css/myStyle.css");
        scene.getStylesheets().add(url.toExternalForm());
        primaryStage.setScene(scene);
        primaryStage.setWidth(800);
        primaryStage.setHeight(650);
        primaryStage.setTitle("JFoeniX测试");
        primaryStage.show();
    }
}
